package com.chen.admin.controller;


import com.chen.admin.common.Result;
import com.chen.admin.entity.CheckIn;
import com.chen.admin.entity.CheckInGuestInfo;
import com.chen.admin.entity.Guest;
import com.chen.admin.service.CheckInService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@CrossOrigin(origins = "http://localhost:8080")
@RequestMapping("/admin")
public class CheckInController {

    @Autowired
    private CheckInService checkInService;

    /**
     * 入住登记
     */

    @PostMapping("/checkInGuest")
    public Result checkInGuest(@RequestBody CheckInGuestInfo guest) {

        Result result = checkInService.checkInGuest(guest);
        return result;

    }

    /**
     * 入住登记列表展示
     */

    @GetMapping("/getCheckInGuestList")
    public Result<PageInfo> getCheckInGuestList(@RequestParam(defaultValue = "1") Integer
                                                pageNumber,@RequestParam(defaultValue = "10") Integer pageSize)
    {
        PageHelper.startPage(pageNumber,pageSize);
       List<CheckInGuestInfo> checkInList= checkInService.getCheckInGuestList();
       return Result.success(new PageInfo(checkInList));
    }
}
